import { mapGetters } from 'vuex'

export default {
	watch: {
		totalGoodsCount: {				// 监听 totalGoodsCount 数据的变化
			handler(){
				this.setTabBarBadge()
			},
			immediate: true
		}
	},
	computed: {
		...mapGetters('cart',['totalGoodsCount'])
	},
	methods: {
		setTabBarBadge(){		// 设置 tabBar 数字徽标
			uni.setTabBarBadge({
				index: 2,
				text: this.totalGoodsCount + ''
			})
		}
	},
	onShow(){
		this.setTabBarBadge()
	}
}